(function($) {
    $.extend({
        myTime: {
            /**
             * 当前时间戳
             * @return <int>        unix时间戳(秒)  
             */
            CurTime: function(){
                return Date.parse(new Date())/1000;
            },
            /**              
             * 日期 转换为 Unix时间戳
             * @param <string> 2014-01-01 20:20:20  日期格式              
             * @return <int>        unix时间戳(秒)              
             */
            DateToUnix: function(string) {
                var f = string.split(' ', 2);
                var d = (f[0] ? f[0] : '').split('-', 3);
                var t = (f[1] ? f[1] : '').split(':', 3);
                return (new Date(
                        parseInt(d[0], 10) || null,
                        (parseInt(d[1], 10) || 1) - 1,
                        parseInt(d[2], 10) || null,
                        parseInt(t[0], 10) || null,
                        parseInt(t[1], 10) || null,
                        parseInt(t[2], 10) || null
                        )).getTime() / 1000;
            },
            /**              
             * 时间戳转换日期              
             * @param <int> unixTime    待时间戳(秒)              
             * @param <bool> isFull    返回完整时间(Y-m-d 或者 Y-m-d H:i:s)              
             * @param <int>  timeZone   时区              
             */
            UnixToDate: function(unixTime, isFull, timeZone) {
                if (typeof (timeZone) == 'number')
                {
                    unixTime = parseInt(unixTime) + parseInt(timeZone) * 60 * 60;
                }
                var time = new Date(unixTime * 1000);
                var ymdhis = "";
                ymdhis += time.getUTCFullYear() + "-";
                ymdhis += (time.getUTCMonth()+1) + "-";
                ymdhis += time.getUTCDate();
                if (isFull === true)
                {
                    ymdhis += " " + time.getUTCHours() + ":";
                    ymdhis += time.getUTCMinutes() + ":";
                    ymdhis += time.getUTCSeconds();
                }
                return ymdhis;
            }
        }
    });
})(jQuery);

function noticePopup(b, a) {
	getSkinColor();
	$(function() {
		var c = $("<div>").appendTo($(".Notice"));
		c.attr("id", "notice" + b);
		$("<div>").addClass("back_body").appendTo(c);
		if ((typeof(skinColor) == "undefined") || (skinColor == null)) {
			skinColor = "blue"
		}
		c.append('<div class="notice_div ' + skinColor + '_back"><a href="#"><div id="notClose' + b + '" class="close_icon"></div></a><div class="notice_icon"><div class="nicon_icon1"></div></div><div class="notice_font">' + a + '</div><div id="notice_button' + b + '" class="notice_button"><a href="#" class="notice_yellow animate">知道</a></div></div>');
		$("#notice_button" + b + " , #notClose" + b).click(function() {
			$("#notice" + b).hide();
			$(".details").hide()
		});
		$(".close_icon , .notice_button").click(function() {
			$(".noticeChild").hide();
			$(".details").hide()
		});
		$(".nicon_button").click(function() {
			$(".noticeChild").hide();
			$(".details").show()
		})
	})
}
$(document).ready(function() {
	$("#footer .more").click(function() {
		getSkinColor();
		
		$.ajax({
            url:"/index.php/Notice/all",
			type:"GET",
			contentType:"application/json",
			dataType:"json",
			data:{ac_id:10,article_show:1},
			success: function(c) {
				$("#dtlFont").html("");
				for (var b = 0; b < c.length; b++) {
					if (b + 1 == c.length) {
						dfClass = 3
					} else {
						if (1 == 0) {
							dfClass = 1
						} else {
							dfClass = 2
						}
					}
					//var a = new Date(c[b].created).toLocaleString();
					var a = $.myTime.UnixToDate(c[b].created,true,8);
					$("#dtlColor").attr("class", "details_div " + skinColor + "_back");
					$("#dtlFont").append('<div class="df' + dfClass + '"><div class="df_data">' + a + "</div><div>" + c[b].text + "</div></div>")
				}
			},
			error: function(a) {
				alert("失败：" + a.code + ",请检查状况後重试。")
			},
			complete: function() {
				$(".details").show()
			}
		})
		return false;
	});
	$(".close_icon , .notice_button").click(function() {
		$(".noticeChild").hide();
		$(".details").hide()
	})
});

function noticePopupWithMore(b, d, c, a) {
	$(function() {
		getSkinColor();
		if ((typeof(skinColor) == "undefined") || (skinColor == null)) {
			skinColor = "blue"
		}
		var e = $("<div>").appendTo($(".Notice"));
		var f = 1;
		e.attr("id", "notice" + d);
		$("<div>").addClass("back_body").appendTo(e);
		$("<div>").addClass("back_body").appendTo(e);
		e.append('<div class="notice_div ' + skinColor + '_back"><a href="#"><div id="notClose' + d + '" class="close_icon"></div></a><div class="notice_page"><a href="#" id="btnPrev' + d + '" class="notice_prev" ><<</a>' + d + "/" + b + '<a href="#" class="notice_next" id="btnNext' + d + '">>></a></div><div class="notice_icon"><div class="nicon_icon1"></div><div class="nicon_button"><a href="#" class="notice_white animate">更多</a></div></div><div class="notice_font">' + c + '</div><div id="notice_button' + d + '" class="notice_button"><a href="#" class="notice_yellow animate">知道</a></div></div>');
		if (d > 1) {
			$("#notice" + d).hide()
		}
		if (d == b) {
			f = 3
		} else {
			if (d == 1) {
				f = 1
			} else {
				f = 2
			}
		}
		$("#dtlColor").attr("class", "details_div " + skinColor + "_back");
		$("#dtlFont").append('<div class="df' + f + '"><div class="df_data">' + a + "</div><div>" + c + "</div></div>");
		$("#notice_button" + d + " , #notClose" + d).click(function() {
			if (d < b) {
				var g = d + 1;
				$("#notice" + g).show()
			}
			$("#notice" + d).hide();
			$(".details").hide()
		});
		$("#btnNext" + d).click(function() {
			if (d < b) {
				var g = d + 1;
				$("#notice" + g).show()
			}
			$("#notice" + d).hide();
			$(".details").hide()
		});
		$("#btnPrev" + d).click(function() {
			if (d > 1) {
				var g = d - 1;
				$("#notice" + g).show();
				$("#notice" + d).hide();
				$(".details").hide()
			}
		});
		$(".nicon_button").click(function() {
			$(".Notice").hide();
			$(".details").show()
		})
	})
}
function redPackPopup() {
	$(function() {
		$.getJSON("payment/getbonusinfo", function(a) {
			if (a.data.length > 0) {
				$.ajax({
					url: "payment/drawbonus",
					type: "GET",
					contentType: "application/json",
					data: {
						transId: a.data[0].id,
						amount: a.data[0].amount
					},
					success: function(b) {
						if (a.success == true) {
							$("#redPack .redpack_amount").text(a.data[0].amount);
							$("#redPack .redpack_remark").text(a.data[0].remark);
							if (!window.IS_MOBILE) {
								loadBonus()
							}
							$("#redPack").show();
							if (!window.IS_MOBILE) {
								loadAccount()
							}
						} else {
							alert(a.message)
						}
					},
					error: function(b) {
						alert("失败：" + b.code + ",请检查状况後重试。")
					},
					complete: function() {
						$("#redPackIcon").hide()
					}
				})
			}
		})
	})
};